package com.zaicheng.cloud.loadbanlancer.server;
/**
 @author zaicheng
 @version 1.0
 @date 2022-04-19
 @email zzc15847256473@163.com
 */

import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.zaicheng.cloud.loadbanlancer.server.impl.NacosServer;
import com.zaicheng.cloud.loadbanlancer.server.impl.NacosServerList;


import java.util.List;
import java.util.Properties;

public class TestServerList {

    public static void main(String[] args) throws NacosException {

        Properties p = new Properties();
        p.put("serverAddr","http://localhost:8848");
        p.put("namespace","dev");

        NamingService namingService = NamingFactory.createNamingService(p);
        ServerList<NacosServer> serverList = new NacosServerList(namingService);

        List<NacosServer> updatedListOfServers = serverList.getUpdatedListOfServers();
        for (NacosServer server:updatedListOfServers){
            System.out.println("获取到服务实例"+server.getInstance().getServiceName());
        }

    }
}
